package com.seata.demo.seatauser.service;

import com.alibaba.fastjson.JSON;
import com.seata.demo.seatauser.entity.Role;
import com.seata.demo.seatauser.entity.User;
import com.seata.demo.seatauser.feign.RoleFeign;
import com.seata.demo.seatauser.mapper.UserMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Autowired
    RoleFeign roleFeign;

    @Override
    public void insert(User user) {
        userMapper.insert(user);
    }

    @Override
    public void addUserRole(User user) {
        userMapper.insert(user);
        Role role=new Role();
        role.setName(user.getUsername());
        role.setSort(user.getAge());
        String content= JSON.toJSONString(role);
    }

    @Override
    public void test() {
        User user=new User();
        user.setUsername("事务");
        user.setAge(12);
        userMapper.insert(user);
        Role role=new Role();
        role.setSort(11);
        roleFeign.add(role);
    }
}
